package cn.tedu._04mybatis.mapper;

import cn.tedu._04mybatis.pojo.entity.Weibo;
import cn.tedu._04mybatis.pojo.vo.*;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface WeiboMapper {
    /*
    1.插入微博
     */

//    @Insert("INSERT INTO  weibo(content,created,user_id) " +
//            "VALUES(#{content},#{created},#{userId}) ")
    int insertWeibo(Weibo weibo);

    /*
    2.删除指定微博
     */
//    @Delete("DELETE FROM weibo WHERE id=#{weiboId}")
    int deleteWeibo(Long weiboId);

//    @Update("UPDATE weibo SET content=#{content},created=#{created}" +
//            ",user_id=#{userId} WHERE id=#{id} ")
    int updateWeibo(Weibo weibo);

//    @Select(("SELECT id,content,created, user_id userId FROM weibo WHERE id=#{userId}"))
    Weibo selectWeiboById(Long weiboId);


//    @Select("SELECT id,content,created, user_id userId FROM weibo ")
    List<Weibo> selectWeibo();


//    @Select("SELECT content,created FROM weibo WHERE id=#{weibo}")
    SelectWeiboVO1 selectWeiboVO1(Long weiboId);

//    @Select("SELECT id,content  FROM weibo WHERE user_id=#{userId}")
    List<SelectWeiboVO2>  selectWeiboVO2(Long userId);


    int dynamicUpdateWeibo (Weibo weibo);

    int dynamicDeleteWeibo1( Long[] ids);



    int dynamicDeleteWeibo2(List<Long> ids);

    int selectCount();

    /**
     * 12.ResultMap单表：根据微博ID查询该条微博的ID、内容、用户ID
     *    SELECT id,content,user_id FROM weibo WHERE id=?
     */
    ResultMapVO1 selectResultMapVO1(Long weiboId);


    ResultMapVO2 selectResultMapVO2(Long userId);

    ResultMapVO3 selectResultMapVO3(Long weiboId);

    ResultMapVO4 selectResultMapVO4(Long weiboId);










}
